package com.jiuwan.gamepass.controller;

import com.jiuwan.gamepass.dto.appJson.AppAllJson;
import com.jiuwan.gamepass.dto.appJson.AppJson;
import com.jiuwan.gamepass.dto.authDto.Result;
import com.jiuwan.gamepass.pojo.App;
import com.jiuwan.gamepass.service.impl.AppServiceImpl;
import com.jiuwan.gamepass.service.impl.UploadServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @version 1.0
 * 功能目的描述 ：用于  app控制层       ========>>>>>>>>>>>
 * @author： pang-yun
 * @date： 2021-06-03 14:19
 */

@Controller
@RequestMapping("app")
public class AppController {


    @Autowired
    private AppServiceImpl appService;

    @Autowired
    private UploadServiceImpl uploadServiceImpl;


    //创建接口
    @RequestMapping("login")
    @ResponseBody

    public AppJson login(String appName, String version) {
        AppJson login = appService.login(appName, version);
        return login;
    }


    //创建plus
    @RequestMapping("loginPlus")
    @ResponseBody
    public AppJson loginPlus(@RequestBody App app) {
        AppJson appJson = appService.loginPlus(app);
        return appJson;

    }


    //postman中测试成功

    @RequestMapping("select")
    @ResponseBody
    public AppAllJson select(String appName) {
        AppAllJson appAllJson = appService.selectApp(appName);
        return appAllJson;
    }


    //postman 测试成功
    @RequestMapping("add")
    @ResponseBody
    public AppJson addApp(@RequestBody App app) {
        AppJson appJson = appService.addApp(app);
        return appJson;
    }


    //PostMan中测试成功

    @RequestMapping("delete")
    @ResponseBody
    public AppJson deleteApp(String appName) {
        AppJson appJson = appService.deleteApp(appName);
        return appJson;
    }


    //查找所有App
    @RequestMapping("selectAll")
    @ResponseBody
    public AppAllJson selectAll() {
        AppAllJson appAllJson = appService.selectAll();

        return appAllJson;
    }


    //分页查询

    /**
     * @param current 当前页数
     * @param size    每页所存有的数量
     * @return
     */
    @RequestMapping("selectPage")
    @ResponseBody
    public Result selectPage(String appName, int current, int size) {
        Result result = appService.selectPage(appName, current, size);
        return result;
    }


    //动态查找接口
    @RequestMapping("selectPlus")
    @ResponseBody
    public AppAllJson selectPlus(String appName) {
        AppAllJson appAllJson = appService.selectPlus(appName);

        return appAllJson;
    }


    //根据uuid删除app信息
    @RequestMapping("deleteByID")
    @ResponseBody
    public AppJson deleteByID(String id) {
        AppJson appJson = appService.deleteByID(id);

        return appJson;
    }


}
